<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2006/04/11 20:58:15 $)
// $RCSfile: troubleshooter.php,v $ : $Revision: 1.8 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* Troubleshooter Module
*/
class troubleshooter {

	/**
	* Constructor to register any events, sections
	*/
	function troubleshooter() {
		global $_SWIFT, $events, $datastore;

		$events->registerEventModuleSWIFT(MODULE_TROUBLESHOOTER, $this);

		// Staff CP
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "managecategories");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "managesteps");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "managestepslist");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "editcategory");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "insertcategory");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "insertstep");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "editstep");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "importexport");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "reports");
		$events->registerEvent(EVENT_STAFF, MODULE_TROUBLESHOOTER, "comments");

		// Client Area
		$events->registerEvent(EVENT_CLIENT, MODULE_TROUBLESHOOTER, "view");
		$events->registerEvent(EVENT_CLIENT, MODULE_TROUBLESHOOTER, "steps");

		$eventaction = $events->eventdata["eventaction"];
		if ($eventaction == "view" || $eventaction == "steps")
		{
			$datastore->cacheLanguageSection("troubleshooter");
		}
	}

	/**
	* Destructor, called to unregister any events etc
	*/
	function _troubleshooter() {
	}

	/*
	* Call back function
	*/
	function _eventcallback($eventtype, $eventaction)
	{
		global $_SWIFT, $interface, $template, $departments, $staffauth, $module, $grid, $xml, $staff, $settings, $dbCore, $events, $session, $loginshare, $cookie, $errormessage, $infomessage, $permissions, $mimelist;

		if ($eventtype == EVENT_STAFF && ($eventaction == "managecategories" || $eventaction == "managesteps" || $eventaction == "insertcategory" || $eventaction == "insertstep" || $eventaction == "importexport" || $eventaction == "editcategory" || $eventaction == "editstep" || $eventaction == "managestepslist")) {
			require_once ("./modules/troubleshooter/staff_troubleshooter.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "reports")) {
			require_once ("./modules/troubleshooter/staff_reports.php");
			return true;
		} else if ($eventtype == EVENT_CLIENT && ($eventaction == "view" || $eventaction == "steps")) {
			require_once ("./modules/troubleshooter/client_troubleshooter.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "comments")) {
			require_once ("./modules/troubleshooter/staff_comments.php");
			return true;
		}				

		return false;
	}
}
?>